cmake_minimum_required(VERSION 3.20)

project(DesignPatterns LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_SIZEOF_VOID_P EQUAL 4)
    set(COMPILEBIT "32")
else ()
    set(COMPILEBIT "64")
endif ()

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message("Setting build type to 'RelWithDebInfo' as none was specified.")
    set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
            "MinSizeRel" "RelWithDebInfo")
endif ()

if (MSVC)
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif (MSVC)

#设置可执行文件的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/Release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/MinSizeRel)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/out/bin${COMPILEBIT}/RelWithDebInfo)
#设置库文件的输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/Debug)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/Release)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/MinSizeRel)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/out/lib${COMPILEBIT}/RelWithDebInfo)

add_subdirectory(Adapter)
add_subdirectory(Bridge)
add_subdirectory(Builder)
add_subdirectory(Chain_of_Responsibility)
add_subdirectory(Command)
add_subdirectory(Composite)
add_subdirectory(Decorator)
add_subdirectory(Facade)
add_subdirectory(Filter)
add_subdirectory(Flyweight)
add_subdirectory(Interpreter)
add_subdirectory(Iterator)
add_subdirectory(Mediator)
add_subdirectory(Memento)
add_subdirectory(Null_Object)
add_subdirectory(Observer)
add_subdirectory(Prototype)
add_subdirectory(Proxy)
add_subdirectory(Singleton)
add_subdirectory(State)
add_subdirectory(Strategy)
add_subdirectory(Template)
add_subdirectory(Visitor)